package com.growthgate.bootcommon.controller;

import com.growthgate.bootcommon.annotation.ApiShowFields;
import com.growthgate.bootcommon.common.base.BaseEntityController;
import com.growthgate.bootcommon.entity.User;
import com.growthgate.bootcommon.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * UserController
 *
 * @author GrowthGate
 * @date 2020/2/17
 */
@Api(tags = "用户")
@RestController
@RequestMapping("/user")
public class UserController extends BaseEntityController<User, UserService> {

    @Autowired
    public UserController(UserService service) {
        super(service);
    }

    @Override
    public Page<User> findAll(@ApiParam("查询条件") @ApiShowFields({"id", "username", "nickname", "sex", "age"}) @RequestBody User entity,
            @ApiParam("页数") @RequestParam(defaultValue = "0") int pageNum,
            @ApiParam("每页条数") @RequestParam(defaultValue = "10") int pageSize) {
        return super.findAll(entity, pageNum, pageSize);
    }

}